package com.ljh.SimpleTradingSystem.mybatis.mapper;

import com.ljh.SimpleTradingSystem.mybatis.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface UserMapper {
    @Select("select * from user where id = #{id}")
    User selectById(int id);

    @Select("select * from user where name = #{name}")
    User selectByName(String name);

    @Insert("insert into user(name, password, errorNum, unlockTime)" +
            "values (#{name}, #{password}, #{errorNum}, #{unlockTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(User user);

    @Update("update user set (errorNum) = #{errorNum} where name = #{name}")
    void updateByName(String name, int errorNum);

    @Update("update user set (unlockTime) = #{unlockTime} where name = #{name}")
    void updateUnlockTimeByName(String name, String unlockTime);

}
